__all__ = [
    "magicMethods",
    "testmethod",
    "testmethod_return",
    "testClass",
    "testAllMethod",
]


magicMethods: list = [
    # "__new__",
    "__init__",
    "__del__",
    "__get__",
    "__set__",
    "__getitem__",
    "__setitem__",
    "__delitem__",
    "__getattr__",
    "__setattr__",
    "__delattr__",
    "__getattribute__",
    "__hash__",
    "__call__",
    "__contains__",
    "__dir__",
    "__delete__",
    "__enter__",
    "__exit__",

    "__add__",
    "__sub__",
    "__mul__",
    "__matmul__",
    "__truediv__",
    "__floordiv__",
    "__pow__",
    "__mod__",
    "__divmod__",

    "__lshift__",
    "__rshift__",
    "__and__",
    "__or__",
    "__xor__",
    "__invert__",
    "__pos__",
    "__neg__",

    "__lt__",
    "__gt__",
    "__eq__",
    "__le__",
    "__ge__",
    "__ne__",

    "__radd__",
    "__rsub__",
    "__rmul__",
    "__rmatmul__",
    "__rtruediv__",
    "__rfloordiv__",
    "__rpow__",
    "__rmod__",
    "__rdivmod__",
    "__rlshift__",
    "__rrshift__",
    "__rand__",
    "__ror__",
    "__rxor__",

    "__iadd__",
    "__isub__",
    "__imul__",
    "__imatmul__",
    "__itruediv__",
    "__ifloordiv__",
    "__ipow__",
    "__imod__",
    "__ilshift__",
    "__irshift__",
    "__iand__",
    "__ior__",
    "__ixor__",

    "__round__",
    "__abs__",
    "__reversed__",
    "__repr__",
    "__len__",

    "__str__",
    "__int__",
    "__float__",
    "__bool__",
    "__complex__",
    "__bytes__",
    "__iter__",
    "__format__",
]


def testmethod(meth: str):
    def printout(self: object, *args) -> None:
        print(meth, *(repr(i) for i in args), sep=' | ')
        return testmethod_return(self, meth)
    return printout


def testmethod_return(self, meth: str):
    return {
        "__init__": None,
        "__int__": 0,
        "__len__": 0,
        "__hash__": 0,
        "__float__": 0.0,
        "__complex__": 0j,
        "__str__": '',
        "__repr__": '',
        "__format__": '',
        "__contains__": False,
        "__bool__": False,
        "__dir__": [],
        "__iter__": iter([]),
        "__bytes__": b'',
    }.get(meth, self)


testClass = type("TestClass", (), {i: testmethod(i) for i in magicMethods})


def testAllMethod(cls: type):  # sourcery skip: remove-unnecessary-cast
    try:
        with cls() as c:
            c+1, c-1, c*1, c/1, c//1, c**1, c % 1, c << 1, c >> 1, c & 1, c | 1, c ^ 1, c@1
            print()
            1+c, 1-c, 1*c, 1/c, 1//c, 1**c, 1 % c, 1 << c, 1 >> c, 1 & c, 1 | c, 1 ^ c, 1@c
            print()
            c += 1
            c -= 1
            c *= 1
            c /= 1
            c //= 1
            c **= 1
            c %= 1
            c <<= 1
            c >>= 1
            c &= 1
            c |= 1
            c ^= 1
            c@=1
            print()
            c < 1, c > 1, c <= 1, c >= 1, c == 1, c != 1
            print()
            ~c, +c, -c, 1 in c
            print()
            int(c), float(c), str(c), complex(c), bool(c), bytes(c)
            print()
            abs(c), round(c), repr(c), len(c), reversed(c), hash(c)
            format(c, "str"), dir(c)
            print()
            c(), c[0], c.c, getattr(c, 'c')
            c[0] = c.c = 1
            del c[0], c.c
            print()
            del c
    except:
        pass
